package com.tengju.user.domain.model.sms;

import com.tengju.user.domain.model.login.UserType;
import com.tengju.user.domain.shared.DomainException;
import com.tengju.user.domain.shared.DomainExceptionCode;
import lombok.Value;
import org.springframework.util.StringUtils;

/**
 * @author wuziyang
 */
@Value
public class CheckSmsCodeData {

    /**
     * 区号
     */
    private String areaCode;

    /**
     * 手机号
     */
    private String mobile;

    /**
     * 用户类型
     */
    private UserType userType;

    /**
     * 操作类型
     */
    private OperationType operationType;

    /**
     * 验证码
     */
    private String code;

    public CheckSmsCodeData(String areaCode,String mobile, UserType userType, OperationType operationType, String code) {
        if (StringUtils.isEmpty(areaCode)) {
            throw DomainException.error(DomainExceptionCode.SYS_PARAMS_NULL,"区号为空");
        }
        if (StringUtils.isEmpty(mobile)) {
            throw DomainException.error(DomainExceptionCode.SYS_PARAMS_NULL,"手机号为空");
        }
        if (userType == null) {
            throw DomainException.error(DomainExceptionCode.SYS_PARAMS_NULL,"用户类型为空");
        }
        if (operationType == null) {
            throw DomainException.error(DomainExceptionCode.SYS_PARAMS_NULL,"操作类型为空");
        }
        if (StringUtils.isEmpty(code)) {
            throw DomainException.error(DomainExceptionCode.SYS_PARAMS_NULL,"手机验证码为空");
        }
        this.areaCode = areaCode;
        this.mobile = mobile;
        this.userType = userType;
        this.operationType = operationType;
        this.code = code;
    }
}
